﻿using System;
using System.Web.UI;
using Library;

namespace DirectoryWeb
{
  /// <summary>
  /// メイン画面のフォームです。
  /// </summary>
  public partial class Main : Page
  {
    #region イベントハンドラ
    protected void Page_Load(object sender, EventArgs e)
    {
      if (this.IsPostBack == false)   //初期表示の時
      {
        this.LogonUserLabel.Text = this.Request.LogonUserIdentity.Name;
        try
        {
          this.StatusLabel.Text = String.Format("ドメイン '{0}' に接続しています。", DirectoryAccess.DomainName);
          this.Button2.Enabled = DirectoryAccess.CanConnectDomain;
        }
        catch
        {
          this.Label1.Visible = true;
          this.Panel1.Enabled = false;
        }
        this.RadioButtonList1.SelectedIndex = Convert.ToInt32(Request.QueryString["idx"]);
      }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      Response.Redirect(String.Format("{0}List.aspx", this.RadioButtonList1.SelectedValue));
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
      Response.Redirect("DomainInfo.aspx");
    }
    #endregion
  }
}